// JavaScript Document
function verify(responseXML) {
	var resp;
	var result = responseXML.getElementsByTagName("result");
	resp = result[0].firstChild.nodeValue;
	//alert(resp);
	
	if (resp == "okay") {
		//alert("okay");
		alert("密码修改成功！");
		window.location="personPage.html";
		
	} else {
		alert("用户名不存在或原密码输入错误！");
		//window.location="register.html";
	}
}

function yesButton_Clicked() {
	if ( document.getElementById("newKey").value == null
			|| document.getElementById("confirmNewKey").value == null
			|| document.getElementById("userName").value == null
			|| document.getElementById("oldKey").value == null
			|| document.getElementById("newKey").value != document.getElementById("confirmNewKey").value
		) {
		alert("输入错误！");
		return;
	}
	var arguments = "<user>";
	arguments = addTag(arguments, "name", document.getElementById("userName").value);
	arguments = addTag(arguments, "password", document.getElementById("oldKey").value);
	arguments = addTag(arguments, "new_password", document.getElementById("newKey").value);
	arguments += "</user>";
	var url = "ChangePassword";
	sendXMLPost(url, arguments, verify);
	
	window.location.href = "index.html";
}

function noButton_Clicked(){
	window.location.href = "index.html";
}